package br.unifor.bd.deadlock;

import br.unifor.bd.protocol.Escalonador;

public class DeadlockFactory {
	
	public static final int WAIT_DIE = 1;
	
	public static final int WAIT_FOR_GRAPH = 2;
	
	public static final int WOUND_WAIT = 3;
	
	public static PrevencaoDeDeadlock obterInstancia(Escalonador escalonador, int tipo) {
		switch (tipo) {
			case WAIT_DIE:
				System.out.println("Utilizando WAIT-DIE prevention");
				return new WaitDie(escalonador);
				
			case WAIT_FOR_GRAPH:
				System.out.println("Utilizando WAIT-FOR-GRAPH prevention");
				return new WaitForGrafo(escalonador);
				
			case WOUND_WAIT:
				System.out.println("Utilizando WOUND-WAIT prevention");
				return new WoundWait(escalonador);
			
			default:
				throw new IllegalArgumentException("Algoritmo de prevencao invalido");
		}
	}

}
